jfblog

Random logs and notes

Publishing on Github

The first thing to do is to create an account on Github pages and then follow the directions. This drives to

  • create a repository, say repo
  • and then create a gh-pages branch

then the content will be available (after a few minutes) in http://username.github.io/repo/

The point is that you will have to publish your materials on gh-pages branch.

Here follows the mydeploy section of my Makefile that I used for that purpose:

In []:
# <!-- collapse=True -->
mydeploy: publish
	   if test -d my_build; \
	   then echo " (_build directory exists)"; \
	   else mkdir my_build; \
	   fi
	   if test -d my_build/$(DEPLOYREPOSITORY); \
	   then echo "  (repository directory exists)"; \
	   else cd my_build && git clone https://github.com/$(USERNAME)/$(DEPLOYREPOSITORY).git \
            cd $(DEPLOYREPOSITORY) && git checkout --orphan gh-pages \ 
            git rm -rf . && rm -f '.gitignore' ; \
	   fi
	   #cd _build/$(DEPLOYREPOSITORY) && git pull
	   rsync -r $(OUTPUTDIR)/* my_build/$(DEPLOYREPOSITORY)/
	   cd my_build/$(DEPLOYREPOSITORY) && git add . && git commit -a -m "make deploy"
	   cd my_build/$(DEPLOYREPOSITORY) && git push origin gh-pages

However, though it seems not said in the recent docs, it is also possible to create a repository with the very same name as user github address; that is for the the http address username.github.io, create a repository username.github.io. In such a case, files pushed to this repository will be available implicitely, and directly at http://username.github.io. In such a case, it is possible to employ the original Makefile's code:

In []:
# <!-- collapse=True -->
deploy: publish
	if test -d _build; \
	then echo " (_build directory exists)"; \
	else mkdir _build; \
	fi
	if test -d _build/$(DEPLOYREPOSITORY); \
	then echo "  (repository directory exists)"; \
	else cd _build && git clone https://github.com/$(USERNAME)/$(DEPLOYREPOSITORY).git; \
	fi
	cd _build/$(DEPLOYREPOSITORY) && git pull
	rsync -r $(OUTPUTDIR)/* _build/$(DEPLOYREPOSITORY)/
	cd _build/$(DEPLOYREPOSITORY) && git add . && git commit -m "make deploy"
	cd _build/$(DEPLOYREPOSITORY) && git push origin master
    
In [1]:
HTML(the_end(theNotebook))
Out[1]:

This post was written as an IPython notebook. It is available for download or as a static html.

Creative Commons License
jfblog by J.-F. Bercher is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Based on a work at http://jfbercher.github.io/.

misc

Comments